package priv.yiyuan.example.design.pay02;

import java.util.HashMap;
import java.util.Map;

/**
 * 支付策略上下文
 *
 * @author YiYuan
 * @data 2025/8/8
 * @apoNote
 */
public class PaymentProcessor {

    private UnifiedPayment paymentMethod;

    private static Map<String, UnifiedPayment> paymentMethods = new HashMap<>();

    public PaymentProcessor(UnifiedPayment paymentMethod) {
        this.paymentMethod = paymentMethod;
    }

    public void executePayment(double amount, String details) {
        paymentMethod.processPayment(amount, details);
    }

    // 注册支付方法
    public static void registerPaymentMethod(String name, UnifiedPayment method) {
        paymentMethods.put(name, method);
    }

    // 获取支付方法
    public static UnifiedPayment getPaymentMethod(String name) {
        return paymentMethods.get(name);
    }


}
